// 初始化按钮状态

export default function updateButtonStatus(orgVal, agreementType,isEdit) {
    let cardFlag = this.state.pageFlag === 'card';
    const optionData = this.props.editTable.getAllRows(agreementType, true);
    const flag = (optionData && optionData.length>0);// 是否有数据
    //设置可见
    this.props.button.setButtonVisible({
        add: !!(orgVal.refpk && !isEdit),
        edit: !!(orgVal.refpk && !isEdit && cardFlag),
        delete: !!(orgVal.refpk && !isEdit),
        text: !!(orgVal.refpk && !isEdit && cardFlag),
        refresh: !!(orgVal.refpk && !isEdit),
        effect: !!(orgVal.refpk && !isEdit),
        file: !!(orgVal.refpk && !isEdit && cardFlag),
        save: !!(orgVal.refpk && isEdit),
        cancel: !!(orgVal.refpk && isEdit),
        query: !!(orgVal.refpk && !isEdit && !cardFlag)
    });
    // 20190709 详情页无editpk时 禁止按钮
    let pkNull = cardFlag && (!this.state.editPk);
    //设置可编辑
    this.props.button.setButtonDisabled({
        edit: (!flag && !cardFlag)||pkNull, //编辑
        delete: (!flag && !cardFlag)||pkNull, //删除
        effect: (!flag && !cardFlag)||pkNull, // 生效

        text:pkNull, //协议文本
        file:pkNull, //协议文本
    });



}
